<article id="wikiArticle">
<div></div>
<p><code><strong>has()</strong></code> 方法根据 <code>WeakSet</code> 是否存在相应对象返回布尔值。</p>
<h2 id="语法">语法</h2>
<pre><code class="language-javascript"><code><em>ws</em>.has(value);</code></code></pre>
<h3 id="参数">参数</h3>
<dl>
<dt>value</dt>
<dd>必须。 测试 <code>WeakSet 中是否存在该对象。</code></dd>
</dl>
<h3 id="返回值">返回值</h3>
<dl>
<dt>Boolean</dt>
<dd>如果 <code>WeakSet</code> 对象中存在指定的元素，返回 true；否则返回 <code>false。</code></dd>
</dl>
<h2 id="示例">示例</h2>
<h3 id="使用_has_方法">使用 <code>has</code> 方法</h3>
<pre><code  class="language-javascript">var ws = new WeakSet();
var obj = {};
ws.add(window);

mySet.has(window);  // 返回 true
mySet.has(obj);     // 返回 false
</code></pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td><a class="external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-weakset.prototype.has" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">WeakSet.prototype.has</small></a></td>
<td><span class="spec-Standard">Standard</span></td>
<td>Initial definition.</td>
</tr>
<tr>
<td><a class="external" href="https://tc39.github.io/ecma262/#sec-weakset.prototype.has" hreflang="en" lang="en" rel="noopener">ECMAScript Latest Draft (ECMA-262)<br/><small lang="zh-CN">WeakSet.prototype.has</small></a></td>
<td><span class="spec-Draft">Draft</span></td>
<td> </td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p></p><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
            This compatibility table still uses the old format,
            because we haven't yet converted the data it contains.
            <strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
<div class="htab">
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
<ul>
<li class="selected"><a>Desktop</a></li>
<li><a>Mobile</a></li>
</ul>
</div><p></p>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td>36</td>
<td><a href="/en-US/Firefox/Releases/34" title="Released on 2014-12-01.">34</a> (34)</td>
<td><span style="color: #f00;">未实现</span></td>
<td>23</td>
<td><span style="color: #f00;">未实现</span></td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Android</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td><span style="color: #f00;">未实现</span></td>
<td>34.0 (34)</td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
</tr>
</tbody>
</table>
</div>
<h2 id="相关链接">相关链接</h2>
<ul>
<li><a href="Reference/Global_Objects/WeakSet" title="WeakSet 对象允许你将弱保持对象存储在一个集合中。"><code>WeakSet</code></a></li>
<li><a href="Reference/Global_Objects/WeakSet/add" title="add() 方法在 WeakSet 对象的最后一个元素后添加新的对象。"><code>WeakSet.prototype.add()</code></a></li>
<li><a href="Reference/Global_Objects/WeakSet/delete" title="delete() 方法从 WeakSet 对象中移除指定的元素。"><code>WeakSet.prototype.delete()</code></a></li>
</ul>
</article>